Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!

Nei San

Greenhorn
+ Follow
since May 08, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nei San

Hi,

Sorry the late reply but I was busy with other activities. I just discovered why my code wasn't working. I had created an Oracle before insert trigger for Person and Address table that used the sequences to insert the primary key value in the tables. I didn't realize that JBOSS invokes the sequences to generate the primary key itself.

Thank you very much for your help.

Nei
Hi,

I have a JSP page that receives the data entered by the user. This page uses JSF.

* register.jsp:



The JSF configuration is:

* faces-config.xml:



So when the user enters the data in the JSP/JSF page and press submit the class Register.java is called with the Person ejb data filled, is that correct? As the Person ejb has the methods getAddress and setAddress, shouldn�t the entity manager create the records in the table Address and in the table Person?

Thank you again.

Nei
Hi,

I added the Column(name =�id�) annotation before the getId() method of Person and Address ejb but I�m getting the same error message about the foreign key violation. My Oracle tables have the following fields:

* Person

Name Type Nullable Default
-------- ------------- -------- -------
ID NUMBER
NAME VARCHAR2(80) Y
ADDRESSID NUMBER(10) Y
EMAIL VARCHAR2(80) Y
PASSWORD VARCHAR2(64) Y
GENDER VARCHAR2(20) Y NULL
...and some more fields

The field ID is the primary key and ADDRESSID is a foreign key.

* Address

Name Type Nullable Default
-------- ------------- -------- -------
ID NUMBER(10)
LINE1 VARCHAR2(255) Y NULL
COUNTRY VARCHAR2(150) Y NULL
POSTCODE VARCHAR2(50) Y NULL

The field ID is the primary key

I have two entity beans called Person and Address.
The data of the tables is entered using the register.jsp page that uses the Register.java class to save the contents to the tables as showed below:



* Register.java:





The EntityFacadeBean uses a EntityManager to save the records in the table and the annotations in the beans are:

* Person.java



* Address.java



The entity manager is responsible for recording the informations in the database, then shouldn�t it be recording the registers in the correct order: the Address first and the Person data after that?

Thank you.

Nei
Hi,

I need an sequence for each table so I changed my code according to your information and worked with the sequence but now I'm getting an error with the foreign key. I have two entity beans Person and Address both of them with the key being generated by two different sequences: person_seq and address_seq. Person has an foreign key that references the field "id" of the Address table.
In the Person ejb I have:



In the Address ejb I have:



Both tables are empty and I'm trying to add an register in the table Person and Address but I'm getting the following error:

ORA-02291: integrity constraint (ADM.FK_ADDRESS) violated - parent key not found

I'm getting some warnings when I start JBOSS:

"14:32:28,570 WARN [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null."

"14:32:28,898 WARN [AnnotationBinder] Hibernate does not support SequenceGenerator.initialValue()"

Do you think these warns have to do with the error message?

Thank you.

Nei
Hi,

I'm trying to use JBOSS IDE for Eclipse but I'm having trouble using an automatic generated id populated from a Oracle sequence previously created in the database. I guess there is some aditional configuration that I need to do in my application but I don't know what it is.

In the persistence XML I have:



At the entity bean I have:



I'm getting the error "java.sql.SQLException: ORA-02289: sequence does not exist".

Thank you.

Nei
Hi there,

I'm sorry making you waste yor time. My problem was a mistake in the URL, instead of using http://localhost:8080/TestInstallation/testStatelessEJB I was typing http://localhost:8080/TestInstallation/testStatetelessEJB.

Thank you.
Hi,

I�m trying to execute an servlet created with Jboss IDE 2.0 for Eclipse and JBOSS 4.0.4. The servlet calls na Stateless EJB 3.0. The compilation is sucessfull and I don�t have any error message during the Jboss statup. It happens that when I type the URL �http://localhost:8080/TestInstallation/testStatetelessEJB� in Firefox i get the foolowing:



The TestInstallation.war and TestInstallation.ejb3 files were generated and deployed with the Jboss IDE. I looked at the Jboss folder after I started it and noticed there is a TestInstallation folder inside �C:\softs\jboss-4.0.4.GA\server\default\work\jboss.web\localhost� but the only content of the folder is a file tldCache.ser. The class file for the servlet is located only in a tmp folder. The TestInstallation.war and TestInstallation.ejb3 are placed in the �C:\softs\jboss-4.0.4.GA\server\default\deploy� folder.

As I said, I�m not getting any error message at the server startup nor when I type the servlet URL.

Below is the log of the server startup.



In the web browse I get the following when I type "http://localhost:8080/status?full=true":



I opened the �JBOSS� AS perpective of Eclipse before but returned it to the Java default. I also run the server in Debug mode before but now I�m running in Normal mode. Do you think these changes affected the environment and may be causing these problems? I already deleted and recreated the server inside Eclipse but it didn�t solve the problem.

I would appreciate any help.

Thank you very much.

Nei
[ May 16, 2007: Message edited by: Nei San ]
Hi,

Is happens there are two files with username and password. I updated the login-config.xml file and forgot the oracle-ds.xml.

I would appreciate if you help with another question:
Do I really have to put the database user and password in the xml files? It doesn't seem a safe thing to do. Is there another way to inform the user and password of the database? Perhaps in the entity bean code?

Thank you.

Nei
Hi,

I already verified the user name and password and I can use them in SGL Plus. Do you think my xml files are missing something? I already copied the file classes12.zip from Oracle to the default\lib path. Can it be a problem with the driver?

Thank you very much.

Nei
Hi there,

I�m trying to execute an Entity EJB 3.0 created with JBOSS IDE 2.0 for eclipse and JBOSS 4.0.4. It happens I�m getting an exception when I start the Jboss server inside eclipse regarding the database. I looked at the JNDI view and there is the entry �OracleDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)�. I�m getting the following exception in the Jboss startup:

19:13:29,480 INFO [Ejb3Configuration] found EJB3 Entity bean: test.ejbs.Person
19:13:29,480 WARN [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
19:13:29,605 INFO [Configuration] Reading mappings from resource: META-INF/orm.xml
19:13:29,605 INFO [Ejb3Configuration] [PersistenceUnit: shoestringPU] no META-INF/orm.xml found
19:13:29,715 INFO [AnnotationBinder] Binding entity from annotated class: test.ejbs.Person
19:13:29,793 INFO [EntityBinder] Bind entity test.ejbs.Person on table Person
19:13:30,090 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
19:13:30,105 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
19:13:37,090 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: ORA-01017: invalid username/password; logon denied
)

I have the following content in the xml files:

The oracle-ds.xml:


The standardjaws.xml:



The standardjbosscmp-jdbc.xml:



The login-config.xml:



The persistence.xml file:



I'm not using hibernate to create the tables. But, as I said, this happens during JBoss startup. I would appreciate any help.

Thank you.

Nei
[ May 15, 2007: Message edited by: Nei San ]
Thank you very much Mark.

I changed the code according your instructions and it worked fine.

Nei
Hi there,

I�m trying to run na EJB application developed with JBOSS IDE 2.0 and JBOSS 4.0.4 GA. I have an remote stateless session bean named TestStatelessBean that inherit from TestStateless. Here is the code for them:

package com.test.ejbs;

import javax.ejb.Remote;

@Remote
public interface TestStateless {
public String testBean();
}

----------------------------------------------------------------------------
package com.test.ejbs;

import javax.ejb.*;
import com.test.ejbs.TestStateless;

public @Stateless class TestStatelessBean implements TestStateless {

public String testBean() {
return "the server returned this string";
}

}
------------------------------------------------------------------------------

I have a servlet that calls the EJB:

package com.test.web;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import java.io.*;

import com.test.ejbs.*;

public class TestStatelessEJBServlet extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = 1L;
private TestStatelessBean statelessBean;

public void init() {
try {
Context context = new InitialContext();
System.out.println("Before lookup");
//statelessBean = (TestStatelessBean) context.lookup("TestStatelessBean/remote");
statelessBean = (TestStatelessBean) context.lookup(TestStatelessBean.class.getName());
System.out.println("After lookup");

} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
writer.write("The stateless bean returned this string: " +
statelessBean.testBean());
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
this.doGet(req, resp);
}
}

--------------------------------------------------------------------

If I try to get the bean with the code �statelessBean = (TestStatelessBean) context.lookup("TestStatelessBean/remote");� I get a class cast exception.

If try to get the bean with the code �statelessBean = (TestStatelessBean) context.lookup(TestStatelessBean.class.getName());� I get a Bean not bound exception.

I deployed my bean with the JBOSS IDE in the files TestInstallation.ejb3 and TetsInstallation.war. My project name is ejb3teste. These two files are in $JBOSS_HOME\server\default\deploy. The content of jndi.properties is:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces
java.naming.provider.url=localhost:1099

The web.xml file contains:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee [url=http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">[/url]
<servlet>
<servlet-name>TestStatelessEJBServlet</servlet-name>
<servlet-class>com.test.web.TestStatelessEJBServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestStatelessEJBServlet</servlet-name>
<url-pattern>/testStatelessEJB</url-pattern>
</servlet-mapping>
</web-app>

The content of the file packaging-buid.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Packaging Generator" default="_packaging_generation_">
<target name="_packaging_generation_" depends="N65540,N65565"/>
<target name="N65540" description="TestInstallation.ejb3">
<jar destfile="TestInstallation.ejb3">
<zipfileset dir="src">
<include name="jndi.properties"/>
</zipfileset>
<zipfileset dir="bin" includes="**/ejbs/*"/>
</jar>
</target>
<target name="N65565" description="TestInstallation.war">
<jar destfile="TestInstallation.war">
<zipfileset dir="src" prefix="WEB-INF">
<include name="web.xml"/>
</zipfileset>
<zipfileset dir="bin" prefix="WEB-INF/classes" includes="**/web/*"/>
</jar>
</target>
</project>

In the jmx-console I have:

jboss.j2ee

* jar=TestInstallation.ejb3,name=TestStatelessBean,service=EJB3
* module=TestInstallation.ejb3,service=EJB3
* service=ClientDeployer
* service=EARDeployer

jboss.web

* J2EEApplication=none,J2EEServer=none,WebModule=//localhost/TestInstallation,j2eeType=Servlet,name=TestStatelessEJBServlet

----------------------------------------------------------

The JNDI Namespace

Global JNDI Namespace

+- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- TestStatelessBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy58 implements interface com.test.ejbs.TestStateless,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)

----------------------------------------------------------------------

I�m calling the servlet with the command line �http://mymachine:8080/TestInstallation/testStatelessEJB�. I have to use this URL because the URL �http://localhost:8080/TestInstallation/testStatelessEJB� doesn�t work. Do you think this can be the cause of the error?

Thank you very much.