How to use embeddable EJB container (Java EE 6 / EJB 3.1) on Mac OS?
To my understanding, the intent of the embeddable EJB 3.1 container is - among others - to support out-of-container testing. I've created a JUnit test case that uses glassfish embeddable for integration testing of ejb 3.1 Light ejbs. I run the tests using Maven.
I have one general problem and one problem specific to Mac OS (I'm not able to use the embeddable container at all on Mac OS).
1. First the general problem: the ejb container does not inject or publish classes that are on the test class-path only:
src>main>java>MyEjb.class
src>test>java>MyTestEjb.class
The test case looks like this:
public class TestCase1b {
static EJBContainer container;
@BeforeClass
public static void initEjbContainer() {
container = EJBContainer.createEJBContainer();
for ( Object property : System.getProperties().keySet() ) {
System.out.print(property + " : ");
System.out.println(System.getProperty((String)property));
@Test
public void canTestWithTransaction() throws NamingException, NotSupportedException, SystemException {
Context ctx = container.getContext();
OrderServiceTesterEjb orderServiceTester = (OrderServiceTesterEjb) ctx
.lookup("java:global/classes/OrderServiceTesterEjb");
Assert.assertNotNull(orderServiceTester.testCreateOrderWithTransaction());
@AfterClass
public static void closeEjbContainer() {
container.close();
The idea with a test-ejb is to mimic the way I typically perform junit integration testing with Spring: the test database i preloaded with test data. Each test-method of the junit test case starts a transaction, invokes the service, evaluates the state of the database and finally performs a rollback. My idea was to mimic that by creating a test ejb (Stateless, REQUIRES_NEW), that injects the EJB to test, calls the method to test, evaluates the result or db state and finally sets rollbackonly before returning. The problem is that the test case can lookup ejbs in src/main/java, but not the "test" ejbs in src/test/java. My workaround is to include the test-EJBs in src/main/java which I think is not acceptable.
2. Next the Mac-problem:
The Mac OS JDK 1.6 contains version 1.0 of javax.annotation (jsr 250). EJBs developed with Java EE 6 depends on version 1.1 of javax.annotation. Specifically, one typically need @Resource(lookup=... and @DataSourceDefinition of javax.annotation.sql which are both missing in the JDK. I can compile my EJBs by adding the javaee-api-6.0.jar library to my classpath. But when running unit tests with maven (as described above), a runtime error is reported, stating that the lookup-property of the @Resource annotation is undefined. This is logical, since the boot classpath should have precedence. So I added javaee-api-6.0.jar to the lib/endorsed directory of the jre. Unfortunetely, this triggers a segmentation fault of the Mac OS JVM when running the test. I have no other workaround than switching to windows. Any help / hints are much appreciated.
/Johan
Just as an update, we're soon to release the WLS 11g R1 PS2 update, which will contain WLS 10.3.3 just to confuse things.
As part of that, we're distributing for the first time, an additional .zip version of WLS to make it easier for developers.
The zip file distribution has no GUI installer -- it's a simple case of unzip, run a script it provides, then start the server.
The zip file distribution has been specifically tested on Mac OS X and the WLS config/domain scripts automatically adjust as necessary for the Mac OS X java environment.
Once the zip file distribution is available, we hope that developing against WLS on Mac OS X (and Windows/Linux) will be an easier task.
-steve-
Similar Messages
-
How to use C-Structure in java applets
hi alls,
I want to use a struct model (struct in C++) in java applets. i know class is used in java applications. but, how can i convert in java applets?
class renk
int r;
int gr;
int b;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Event;
import java.applet.Applet;
public class benek extends Applet
final int n=10;
int x[] = new int[n];
int y[] = new int[n];
int count = 0;
renk clr[] = new renk[n];
public void init()
setBackground(Color.black);
public boolean mouseDown(Event yordam, int xyer, int yyer)
if (count<n)
System.out.println("...");
ekle(xyer,yyer);
else System.out.println("Kapasite Doldu...");
return true;
void ekle(int xyer, int yyer)
int r1 = (int)Math.floor(Math.random()*256);
int gr1 = (int)Math.floor(Math.random()*256);
int b1 = (int)Math.floor(Math.random()*256);
clr[count].r = r1;
clr[count].gr = gr1;
clr[count].b = b1;
x[count]=xyer;
y[count]=yyer;
count++;
repaint();
public void paint(Graphics g)
it gives error message... how can � use struct model in java applets???
if you help me i will be greatfull....� use import but it doesn't work.
i add: import renk; or import class renk;
how will � add import I assumed based on your initial post that the renk and benek classes were in the same file. Apparently you're saying they are not. So for another thing, make your renk class "public class renk", and add the "public" keyword to the 3 members of that class. Then if your code still doesn't see the "renk" class, it would just be that you don't have the directory that contains the compiled "renk.class" in your classpath. -
How to use openjpa + kodo in Java SE?
Hi.
We are developing J2EE application on Weblogic Server 9. For a part of application we should create unit tests that will be run in Java SE. How to use openjpa + kodo in Java SE?Hi,
Try the EclipseLink JPA JEE5/JEE6 provider - it has been shipping as part of WebLogic Server since 10.3.1.0.
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
The following page has several SE, application-managed and container-managed EE example tutorials with source.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial
http://wiki.eclipse.org/EclipseLink/Examples/JPA
The following forum will help you with any JPA specific issues.
Forum: TopLink/JPA
TopLink/JPA
thank you
/michael
http://www.eclipselink.org -
Hi
I am just a starter on WLPortal.
I have created a barebone Application from scratch. I have synchronized it properly
from EBCC to WLP. But When I am trying to access the home page of my application,
I am getting from stack trace -
<Nov 6, 2002 5:37:59 PM IST> <Error> <PortalAppflow> <Could not lookup PortalManagerHome
in the JNDI tree using EJB reference java:comp/env/ejb/PortalManager.
javax.naming.NameNotFoundException: Unable to resolve comp/env/ejb/PortalManager
Resolved: 'comp/env' Unresolved:'ejb' ; remaining name 'PortalManager'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:802)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:209)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:173)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:181)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:181)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:36)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:124)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at com.bea.p13n.util.JndiHelper.lookupNarrow(JndiHelper.java:96)
at com.bea.portal.appflow.PortalAppflowHelper.<clinit>(PortalAppflowHelper.java:64)
at com.bea.portal.appflow.servlets.internal.PortalWebflowServlet.init(PortalWebflowServlet.java:78)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:700)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:643)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:588)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:368)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:242)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:215)
at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:112)
at jsp_servlet.__index._jspService(__index.java:92)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:304)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2459)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
<Nov 6, 2002 5:37:59 PM IST> <Error> <HTTP> <[WebAppServletContext(19695286,FirstWebApp,/FirstWebApp)]
Servlet failed with Exception
java.lang.NullPointerException:
at com.bea.portal.appflow.PortalAppflowHelper.createPortalManager(PortalAppflowHelper.java:82)
at com.bea.portal.appflow.servlets.internal.PortalWebflowServlet.setupPortalRequest(PortalWebflowServlet.java:187)
at com.bea.portal.appflow.servlets.internal.PortalWebflowServlet.doGet(PortalWebflowServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:215)
at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:112)
at jsp_servlet.__index._jspService(__index.java:92)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:304)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2459)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
When I decompiled the class PortalAppflowHelper, I found a static block in it,
which was as under-
static
debug = Debug.getInstance(com.bea.portal.appflow.PortalAppflowHelper.class);
try
if(debug.ON)
debug.out("Looking up PortalManagerHome using EJB reference java:comp/env/ejb/PortalManager");
portalManagerHome = (PortalManagerHome)JndiHelper.lookupNarrow("java:comp/env/ejb/PortalManager",
com.bea.portal.manager.ejb.PortalManagerHome.class);
if(debug.ON)
debug.out("Successfully retrieved PortalManagerHome " + portalManagerHome);
catch(Exception e)
PortalAppflowLogger.errorFindingPortalManagerHome("java:comp/env/ejb/PortalManager",
e);
I have checked the PortalManager's JNDI name on WLConsole. Its ${APPNAME}.BEA_portal.PortalManager.
Should I change it?
When I tried to change it, I started getting other weird errors.
Thanks
Neeraj HansNeeraj -
The Portal framework code (including PortalAppflowHelper) uses ejb
references to find the PortalManager (and other EJBs) from servlets and
taglibs; that is what is signified by the java:comp/env/... name.
Since you built your webapp from scratch (instead of using the portal
wizard), you will need to make sure the you have the appropriate
<ejb-ref> entries in your web.xml, and the corresponding
<ejb-reference-description> entries in your weblogic.xml. By default,
you will need at least mappings for:
- ejb/PortalManager
- ejb/UserManager
- ejb/GroupManager
- ejb/PipelineExecutor
- ejb/EventService
See either the resulting webapp from using the portal wizard or
BEA_HOME/weblogic700/samples/portal/sampleportalDomain/beaApps/sampleportal/sampleportal/WEB-INF
for example syntax.
Greg
Neeraj Hans wrote:
Hi
I am just a starter on WLPortal.
I have created a barebone Application from scratch. I have
synchronized it properly
from EBCC to WLP. But When I am trying to access the home page of my
application,
I am getting from stack trace -
<Nov 6, 2002 5:37:59 PM IST> <Error> <PortalAppflow> <Could not lookup
PortalManagerHome
in the JNDI tree using EJB reference java:comp/env/ejb/PortalManager.
javax.naming.NameNotFoundException: Unable to resolve
comp/env/ejb/PortalManager
Resolved: 'comp/env' Unresolved:'ejb' ; remaining name 'PortalManager'
at <stack trace lines snipped>
When I decompiled the class PortalAppflowHelper, I found a static
block in it,
which was as under-
static
debug =
Debug.getInstance(com.bea.portal.appflow.PortalAppflowHelper.class);
try
if(debug.ON)
debug.out("Looking up PortalManagerHome using EJB
reference java:comp/env/ejb/PortalManager");
portalManagerHome =
(PortalManagerHome)JndiHelper.lookupNarrow("java:comp/env/ejb/PortalManager",
com.bea.portal.manager.ejb.PortalManagerHome.class);
if(debug.ON)
debug.out("Successfully retrieved PortalManagerHome "
+ portalManagerHome);
catch(Exception e)
PortalAppflowLogger.errorFindingPortalManagerHome("java:comp/env/ejb/PortalManager",
e);
I have checked the PortalManager's JNDI name on WLConsole. Its
${APPNAME}.BEA_portal.PortalManager.
Should I change it?
When I tried to change it, I started getting other weird errors.
Thanks
Neeraj Hans -
How to use sql query in java ?
i don't know how to use sql query in java code.
who can give me some advice?
thankshttp://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/
-
How to use " toFront() " method in java application and in which package or
How to use " toFront() " method in java application and in which package or class having this toFront() method.if anybody know pl. send example.
The API documentation has a link at the top of every page that says "Index". If you follow that and look for toFront(), you will find it exists in java.awt.Window and javax.swing.JInternalFrame.
To use it in a Java application, create an object x of either of those two classes and write "x.toFront();". -
How to use XML / XPath in JAVA (in 1.4)
I'm absolutely novice in XML
but I need to query XML using XPath
As I understand XPath become avalible only in Java 1.5
But I use 1.4 (project requirement)
Which third part component could you recomend?Can anyone help me with this XPath query
I get result [title: null]
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import org.jaxen.*;
import org.jaxen.dom.*;
import org.jaxen.saxpath.*;
import java.util.*;
public class TestX {
public void ggg() {
try {
File f = new File("journal.xml");
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
org.w3c.dom.Document doc = docBuilder.parse(f);
XPath xpath = new DOMXPath( "/journal/article/title" );
List result = (List) xpath.evaluate(doc);
System.out.println(result.get(0));
} catch (Exception e) {
e.printStackTrace();
public static void main(String[] args) {
TestX tx = new TestX();
tx.ggg();
}journal.xml
<journal>
<article id="article.1">
<title>Art1</title>
<author>
<first>Bob</first>
<last>McWhirter</last>
</author>
<text>
</text>
</article>
<article id="article.2">
<title>Art2</title>
<author>
<first>James</first>
<last>Strachan</last>
</author>
<text>
</text>
</article>
</journal> -
How to use acrobat viewer for java enabled platform
i want to use any api which can generate automatically pdf files and whose control goes through the java program.
i found that adobe is providing one zip file(acrobat viewer) for it.it contains some class files.but i dont know how to use it.
can anybody help me?
or if u can suggest any free api for this purpose?
its urgent.i'll be thankful 2 u.http://forum.java.sun.com/thread.jspa?forumID=31&threadID=792789
-
How to use excel api in java?
I need to use excel api in Java to generate data in excel format. Can any one tell any of the use ful Excel api that we can down load from net? i have read about Apache's POi-hssf-Java api. But the jar i downloaaded from Apache site is not working ? Can anybody please send me the jar for taht Api ?
Hi,
In fact i was not clear about whcih jar file to download from the apache site. i found one folder structure like this
-parent
-bin
-src
All these folders contained some zip files. i took the zip files and extracted them. And i set teh class path also . But when i tried to import in java programs ,these jar files are giving compilation errors -
How to use a JCO connection pool in an EJB?
Hi *,
I want to build a WebService using SAP Web AS (J2EE Engine) that connects to a R/3 ERP (release 4.7).
I thought of building a stateless session bean that will be deployed as webservice. The session bean shall connect to the R/3 in order to call some BAPIs. I'd like to use a JCO connection pool. But I'm not sure, where I should create and destroy the connection pool. Are the EJB methods ejbCreate() and ejbRemove() the right ones? If so, my businness methods would just have to get a connection from the pool and call the BAPIs, right? If not, what do you suggest?
Another question: I already deployed a bean as webservice. Since not really knowing how to use the connection pool, I created a bean with one business method that creates a connection pool whenever it gets called. But if I have to change something in the bean so that I have to redeploy the bean I can't call my business method anymore, because JCO cannot load a native library once again, as it is already loaded, This leads to an exception. So I have to restart the complete engine everytime I redeploy my bean. Are there any workarounds for this problem? I'm not sure whether this is connected to the wrong use of the JCO connection pool.
Kind regards,
LarsHi *,
I want to build a WebService using SAP Web AS (J2EE Engine) that connects to a R/3 ERP (release 4.7).
I thought of building a stateless session bean that will be deployed as webservice. The session bean shall connect to the R/3 in order to call some BAPIs. I'd like to use a JCO connection pool. But I'm not sure, where I should create and destroy the connection pool. Are the EJB methods ejbCreate() and ejbRemove() the right ones? If so, my businness methods would just have to get a connection from the pool and call the BAPIs, right? If not, what do you suggest?
Another question: I already deployed a bean as webservice. Since not really knowing how to use the connection pool, I created a bean with one business method that creates a connection pool whenever it gets called. But if I have to change something in the bean so that I have to redeploy the bean I can't call my business method anymore, because JCO cannot load a native library once again, as it is already loaded, This leads to an exception. So I have to restart the complete engine everytime I redeploy my bean. Are there any workarounds for this problem? I'm not sure whether this is connected to the wrong use of the JCO connection pool.
Kind regards,
Lars -
How to use host variable in Java?
How do I use host variable in java? I am getting SQL code of -404 and description of SQL code is The UPDATE or INSERT statement specifies a String that is too long column-name SQLSTATE=22001. Below is my code:
* i n s e r t M e s s a g e
* insertMessage: This method will retrive detail message and other fields for
* selected item from screen1.
public final Collection insertMessage(String businessId,String messageNumber,String messageType,
String messageTitle,String printStyle,String statusIndicator,
String approverId,String lastUpdateId,String longMessage) {
MessageTransport msi = new MessageTransport();
PreparedStatement ps = null;
Connection connection = null;
MessageTransport msi1 = new MessageTransport();
PreparedStatement ps1 = null;
Connection connection1 = null;
ArrayList list = new ArrayList();
try {
if (businessId != null) {
businessId = businessId.trim();
if (messageNumber != null) {
messageNumber = messageNumber.trim();
if (messageType != null) {
messageType = messageType.trim();
if (messageTitle != null) {
messageTitle = messageTitle.trim();
if (printStyle != null) {
printStyle = printStyle.trim();
if (statusIndicator != null) {
statusIndicator = statusIndicator.trim();
if (approverId != null) {
approverId = approverId.trim();
if (lastUpdateId != null) {
lastUpdateId = lastUpdateId.trim();
if (longMessage != null) {
longMessage = longMessage.trim();
int len = longMessage.length();
if (len > 254) {
int constant = 254;
int k = len % constant; //k will hold value that has number of loops including initial insert.
k = k - 1; //this is for total number of loop.
int j = len / constant; //this will have remainder if any to insert rest of longmessage.
System.out.println("Display remainder: " + k);
System.out.println("Display divisible: " + j);
System.out.println("Display Length of longMessage: " + len);
StringBuffer sql = new StringBuffer();
sql.append("INSERT INTO " + MESSAGE_TBL + " ( MT_BUS_ID,MT_MSG_NBR,MT_MSG_TYPE,MT_MSG_TITLE,MT_PRINT_STYLE,MT_APV_STATUS,MT_APV_ID,MT_APV_DT,MT_APV_TM,MT_LAST_UPDATE_ID,MT_LAST_UPDATE_DT,MT_LAST_UPDATE_TM,MT_MSG_TXT ) VALUES ");
sql.append("(");
sql.append("'");
sql.append(businessId).append("'");
sql.append(",").append(messageNumber);
sql.append(",").append("'I'");
sql.append(",").append("'").append(messageTitle).append("'");
sql.append(",").append("'").append(printStyle).append("'");
sql.append(",").append("'P'");
sql.append(",").append("' '");
sql.append(",").append("CURRENT DATE");
sql.append(",").append("CURRENT TIME");
sql.append(",").append("'").append(lastUpdateId).append("'");
sql.append(",").append("CURRENT DATE");
sql.append(",").append("CURRENT TIME");
sql.append(",").append("'").append(longMessage).append("'");
sql.append(")");
System.out.println("Display SQL Statement: " + sql);
connection = DriverManager.getConnection(DATABASE_URI, USER, PASS);
ps = connection.prepareStatement(sql.toString());
ps.executeUpdate();
System.out.println("Refreshed Record: ");
catch (SQLException sqle) {
System.out.println("SQLException: "+ sqle + ". SQLSTATE=" + sqle.getSQLState()+" SQLCODE=" + sqle.getErrorCode());
finally {
if (ps != null) {
try {
ps.close();
ps=null;
catch (Exception e) {}
if (ps1 != null) {
try {
ps1.close();
ps1=null;
catch (Exception e) {}
if (connection != null) {
try {
connection.close();
connection = null;
catch (Exception e) {}
if (connection1 != null) {
try {
connection1.close();
connection1 = null;
catch (Exception e) {}
return list;
if my longMessage is smaller like one line then everything works fine, but as soon as my longMessage if greater than 254 it starts giving me -404. How do I work around or Is there any way to use host variable in Java?
All kind of help is appreciated. Any question then please email me at [email protected].
Thank you.This is what you got to do to insert a larger value.
//Assuming that message length is less than 254+ 254 characters.
//If larger then run the update loop that many times.
String longMessage = "Blah blah ... ";
String firstPart = "";
String secondPart = "";
int messageLength = longMessage.length();
if (messageLength > 254)
try
firstPart = longMessage.subString(0, 253);
secondPart = longMessage.subString(254, message);
catch (IndexOutOfBoundsException e)
//In the first insert set the first 254 characters
ps.setString(1, firstPart);
int result = ps.executeUpdate();
if (result != 0)
System.out.println("Insert sucessful ");
if (messageLength > 254)
//now update with the second part.
static String UPDATE_SECOND_PART = UPDATE my.table SET LONG_COL = LONG_COL || ? WHERE KEY_COL = ?;
ps2 = connection.getPreparedStatement(UPDATE_SECOND_PART);
ps2.setString(1, secondPart);
ps2.setString(2, businessId); //assuming that businessId is the primary key.
int result2 = ps2.executeUpdate();
if (result2 != 0)
System.out.println("Update sucessful ");
else
System.out.println("Update failed ");
else
System.out.println("Insert failed ");
}Hope this helps. -
How to use the build-in Java parser
Hi All,
I want do use the build-in Java parser. Is this possible? For example I have the following code:
package ch.fhnw;
import javax.tools.*;
public class JavacExample {
* @param args
public static void main(String[] args) {
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
String arguments = "./src/ch/fhnw/JavacExample.java";
int rc = javac.run(null , null, null, "-verbose", arguments);
System.out.println("Return value: " + rc);
}After parsing, it would be great to have an object or similar which contains the methods, arguments used by the methods, etc. The target is to extract method declarations from java files. Is there a simple way to do it without defining my own EBNF like in JavaCC? Or any other way?
Thank you for your help.
kind regards,
wolfgangYep. bootstrap your knowledge here
[http://java.sun.com/javase/6/docs/technotes/guides/javac/index.html]
[http://forum.java.sun.com/forum.jspa?forumID=514]
Bruce -
How to Use Exec function in Java Code
How to Use Exec method
I want to Execute command
net Start "some service"
using exec method of runtime class
or i use some other way if suggestAssuming you have read http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String) already, I can only suggest to be more specific in what your problems are. If you are after just some example code, then download ftp://ftp.ebi.ac.uk/pub/software/textmining/monq/monq.tar.gz and have a look at the source code of monq.stuff.Exec. It does all those things which are necessary to keep track of a Process after it was created with exec.
Harald.
BioMed Information Extraction: http://www.ebi.ac.uk/Rebholz-srv/whatizit -
How to use XSLT processor in java to get xml
hi friends,
i have raw xml and xsl files as input to xsltprocessor which should give xml as output.
my raw xml and xsl looks like this:-
name_space.xml:-
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly'>
<s:AttributeType name='ID' rs:number='1' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='CODE' rs:number='2' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='NAME' rs:number='3' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='255'/>
</s:AttributeType>
<s:AttributeType name='SOURCE' rs:number='4' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10'/>
</s:AttributeType>
<s:AttributeType name='IDENT' rs:number='5' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='128'/>
</s:AttributeType>
<s:AttributeType name='OBS_LEVEL' rs:number='6' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
</s:AttributeType>
<s:AttributeType name='ATA_CODE' rs:number='7' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='12'/>
</s:AttributeType>
<s:AttributeType name='SCORE' rs:number='8' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true'/>
</s:AttributeType>
<s:AttributeType name='HAS_EFF_NOTE' rs:number='9' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ID='1018' CODE='OBSV' NAME='ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE RIGHT SIDE'
SOURCE='' IDENT='' OBS_LEVEL='' ATA_CODE='32-43' SCORE='1'
HAS_EFF_NOTE='0'/>
<z:row ID='1017' CODE='OBSV' NAME='ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE LEFT SIDE'
SOURCE='' IDENT='' OBS_LEVEL='' ATA_CODE='32-43' SCORE='1'
HAS_EFF_NOTE='0'/>
<z:row ID='100' CODE='LOCAL' NAME='ACCU PRESS DROPS VERY QUICKLY PARKING BRAKE OFF'
SOURCE='' IDENT='' OBS_LEVEL='INDICATOR(S)' ATA_CODE='32-44'
SCORE='1' HAS_EFF_NOTE='0'/>
</rs:data>
</xml>
and my XSL File:-
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" exclude-result-prefixes="rs z">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
- <xsl:template match="//xml/rs:data">
- <Entities Count="{count(z:row)}">
<xsl:apply-templates select="z:row" />
</Entities>
</xsl:template>
- <xsl:template match="z:row">
<Entity ID="{@ID}" ATA="{@ATA_CODE}" Name="{@NAME}" Code="{@CODE}" Source="{@SOURCE}" Ident="{@IDENT}" Level="{@OBS_LEVEL}" EffNote="{@HAS_EFF_NOTE}" Score="{@SCORE}" />
</xsl:template>
</xsl:stylesheet>
AND I NEED OUTPUT XML AS:-
<Entities Count="3">
<Entity ID="1018" ATA="32-43" Name="ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE RIGHT SIDE" Code="OBSV" Source="" Ident="" Level="" EffNote="0" Score="1"></Entity>
<Entity ID="1017" ATA="32-43" Name="ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE LEFT SIDE" Code="OBSV" Source="" Ident="" Level="" EffNote="0" Score="1"></Entity>
<Entity ID="100" ATA="32-44" Name="ACCU PRESS DROPS VERY QUICKLY PARKING BRAKE OFF" Code="LOCAL" Source="" Ident="" Level="INDICATOR(S)" EffNote="0" Score="1"></Entity>
</Entities>
how to write a bean to get this xmloutput.
thank in advanceHi Sliba,
You may download and use the XDK for Java that is available from OTN to do this.
Here is the code that will be handy for use. Just substitute your XML document and stylesheet
in the code snippet pasted below. I hope this helps.
There are many more useful XML samples you can find at http://otn.oracle.com/sample_code/tech/xml/content.html
Regards
Abhijeet
// import the necessary libraries
import oracle.xml.parser.v2.XSLProcessor;
import oracle.xml.parser.v2.XSLStylesheet;
import oracle.xml.parser.v2.XMLDocument;
import oracle.xml.parser.v2.DOMParser;
import java.io.StringReader;
public class Test
public Test()
// Xml document that needs to be transformed
private static String xmldoc = "<xml xmlns:s=\"http:www.myschema.com\" >" +
"<s:result>" +
"<s:status>1234554321</s:status>"+
"<s:approvalcode>1234567887654321</s:approvalcode> "+
"</s:result>" +
"</xml>";
// Xsl stylesheet that will be applied
private static String xsldoc ="<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:s=\"http:www.myschema.com\" > " +
" <xsl:template match=\"s:result\"> "+
" My transform status: <xsl:value-of select=\"s:status\"/> <BR/>" +
" My transform Approval code : <xsl:value-of select=\"s:approvalcode\"/> " +
"</xsl:template> " +
"</xsl:stylesheet> ";
public void transform(String xmlstr,String xslstr) throws Exception {
// Create the DOM parser instance
DOMParser dp = new DOMParser();
// Create StringReader object
StringReader xmlreader = new StringReader(xmlstr);
// Parse the xml document string
dp.parse(xmlreader);
// Get java object representation of XML document
XMLDocument xmldoc = dp.getDocument();
// Create an instance of XSL processor
XSLProcessor processor = new XSLProcessor();
// Create StringReader object
StringReader xslreader = new StringReader(xslstr);
// Parse the xsl stylesheet
XSLStylesheet xsl = processor.newXSLStylesheet(xslreader);
processor.showWarnings(true);
processor.setErrorStream(System.err);
processor.processXSL(xsl,xmldoc,System.out);
return;
public static void main(String[] args) throws Exception
Test test = new Test();
System.out.println("Executing test");
test.transform(xmldoc,xsldoc);
} -
How to use directory alias in Java stored procedure ?
hi everyone !
I want use Directory alias in Java strored procedure
I 'hv created dir alias as
Create Directory BFILE_DIR AS 'C:\MyImages'
my java statements -
myfile="C:\MyImages\myPH01.jpg"
File binaryFile = new File(myFile);
instead of giving absolute path I want give directory alias BFILE_DIR
myfile= BFILE_DIR + "myPH01.jpg"
File binaryFile = new File(myFile);
can anyone pl suugest how should I write this in Java procedure
thanks
SPDhi everyone !
I want use Directory alias in Java strored procedure
I 'hv created dir alias as
Create Directory BFILE_DIR AS 'C:\MyImages'
my java statements -
myfile="C:\MyImages\myPH01.jpg"
File binaryFile = new File(myFile);
instead of giving absolute path I want give directory alias BFILE_DIR
myfile= BFILE_DIR + "myPH01.jpg"
File binaryFile = new File(myFile);
can anyone pl suugest how should I write this in Java procedure
thanks
SPD
Maybe you are looking for
-
IPhone now only vibrating a few times?
When I got a phone call, my iPhone 5 would vibrate until the call went to voicemail, or until I hit the lock button. Now it seems it is vibrating only a few times (I want to say four times) until it just stops vibrating - but the call is still going.
-
Whats the dfference between IDOC, ALE and EDI?
whats the dfference between IDOC, ALE and EDI?
-
Make photos vertical from horizontal?
imac Mac OS X (10.4.7) Is it possible to change a photo from a horizontal to a vertical? Can I compress the photo in some way so that the 4x6 dimension goes vertically instead of horizontally? Please help--I'm trying to make family photos work in
-
Sort Mail Inbox Search by From?
In the past Mail versions, when you searched mail in the Inbox, it would show you who SENT the message. Mountain Lion Mail shows me who it was sent TO. That's funny because it's always me, obviously, it's my inbox. Anyway to set it back to showing me
-
How to? Overlapping slice image swaps.
I've done research into overlapping slices but not finding any specific help to what I'm trying to do, so I thought I would post my question here, along with a very basic visual example of the intended functionality. http://img219.imageshack.us/img21