配置问题java.lang.NoClassDefFoundError

skygege20 2015-07-24 03:33:04
我是使用两个jdbc连接不同的数据库:如:jdbc:mysql://X.X.X.X:3306/dome1?characterEncoding=utf-8&allowMultiQueries=true 和jdbc:mysql://X.X.X.X:3306/dome2?characterEncoding=utf-8&allowMultiQueries=true
配置两个连接池
报错信息:
2015-7-24 14:26:17 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.tv189.core.web.ContextLoaderListener
java.lang.NoClassDefFoundError: IllegalName: com.tv189.elip/ax/user/service/dao/AXUserAnswerCalcDao
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:476)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.tv189.core.util.ClassUtil.findClasses(ClassUtil.java:79)
at org.tv189.core.util.ClassUtil.findClasses(ClassUtil.java:31)
at org.tv189.core.ResourceScanHelper.scan(ResourceScanHelper.java:20)
at org.tv189.core.web.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:19)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2015-7-24 14:26:17 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-7-24 14:26:17 org.apache.catalina.core.StandardContext start
严重: Context [/message_processor] startup failed due to previous errors

配置文件:
<bean id="elip-ax-dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${elip.ax.jdbc.driverClassName}" />
<property name="url" value="${elip.ax.jdbc.url}" />
<property name="username" value="${elip.ax.jdbc.username}" />
<property name="password" value="${elip.ax.jdbc.password}" />
<property name="maxActive" value="${elip.ax.jdbc.maxActive}" />
<property name="maxWait" value="${elip.ax.jdbc.maxWait}" />
<property name="maxIdle" value="${elip.ax.jdbc.maxIdle}" />
<property name="removeAbandoned" value="${elip.ax.jdbc.removeAbandoned}" />
<property name="removeAbandonedTimeout" value="${elip.ax.jdbc.removeAbandonedTimeout}" />
<property name="logAbandoned" value="${elip.ax.jdbc.logAbandoned}" />
<property name="initialSize" value="1" />
<property name="defaultAutoCommit" value="true" />
<property name="validationQuery" value="SELECT 1" />
<!-- <property name="testOnCreate" value="true" /> -->
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="true" />
</bean>

<!-- sessionFactory 定义 -->
<bean id="elip_ax_sessionFactory"
class="org.tv189.core.db.hibernate.annotation.AnnotationSessionFactoryBeanWithJar">
<property name="dataSource">
<ref bean="elip-ax-dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${elip.ax.hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${elip.ax.hibernate.show_sql}</prop>
<prop key="hibernate.max_fetch_depth">${elip.ax.hibernate.max_fetch_depth}</prop>
<prop key="hibernate.jdbc.fetch_size">${elip.ax.hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${elip.ax.hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.jdbc.use_scrollable_resultset">${elip.ax.hibernate.jdbc.use_scrollable_resultset}</prop>
<!-- <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> -->
<prop key="hibernate.cache.use_second_level_cache">${elip.ax.hibernate.cache.use_second_level_cache}</prop>
</props>
</property>
<!-- 如要采用注解方式建立映射,所有对象须放在此包下 -->
<!-- <property name="packagesToScan" value="com/tv189/elip/user/service/entity"></property> -->
<property name="jarResourcesToScan">
<list>
<value>/WEB-INF/lib/elipSyncAxAnswer.jar</value>
</list>
</property>
</bean>
<!-- 开启事务注解机制 -->
<bean id="elip_ax_transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="elip_ax_sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="elip_ax_transactionManager"
proxy-target-class="true" />

<bean id="axUserAnswerDao" class="com.tv189.elip.ax.user.service.dao.AXUserAnswerDao">
<property name="sessionFactory" ref="elip_ax_sessionFactory" />
</bean>
<bean id="axUserErrorDao" class="com.tv189.elip.ax.user.service.dao.AXUserErrorDao">
<property name="sessionFactory" ref="elip_ax_sessionFactory" />
</bean>
<bean id="axUserAnswerCalcDao" class="com.tv189.elip.ax.user.service.dao.AXUserAnswerCalcDao">
<property name="sessionFactory" ref="elip_ax_sessionFactory" />
</bean>

<bean id="axAnswerProcessor" class="com.tv189.elip.ax.user.service.processor.AXAnswerProcessor">
<property name="axUserAnswerDao" ref="axUserAnswerDao" />
<property name="axUserErrorDao" ref="axUserErrorDao" />
<property name="axUserAnswerCalcDao" ref="axUserAnswerCalcDao" />
</bean>
...全文
185 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
skygege20 2015-07-24
可以看出preDefineClass方法首先对类名进行了检查,发现以java作为一级包名,则抛出安全异常:禁止使用的包名! 这条安全异常是由Java类加载的“双亲委派模型”所导致的。在双亲委派模型中,由父加载类加载的类,下层加载器是不能加载的。本例中最高层加载器BootstrapClassLoader加载了classpath路径下所定义的java.*包内的类,而java.research包就不能由BootstrapClassLoader的下层加载器AppClassLoader加载了。这也是java安全机制中对于恶意代码所采取的防护措施。
  • 打赏
  • 举报
回复
skygege20 2015-07-24
已处理:根据异常信息,定位到java.lang.ClassLoader.preDefineClass进行排查,发现以下代码片断: /* Determine protection domain, and check that: - not define java.* class, - signer of this class matches signers for the rest of the classes in package. */ private ProtectionDomain preDefineClass(String name, ProtectionDomain protectionDomain) { if (!checkName(name)) throw new NoClassDefFoundError("IllegalName: " + name); if ((name != null) && name.startsWith("java.")) { throw new SecurityException("Prohibited package name: " + name.substring(0, name.lastIndexOf('.'))); } if (protectionDomain == null) { protectionDomain = getDefaultDomain(); } if (name != null) checkCerts(name, protectionDomain.getCodeSource()); return protectionDomain; } ...... // true if the name is null or has the potential to be a valid binary name private boolean checkName(String name) { if ((name == null) || (name.length() == 0)) return true; if ((name.indexOf('/') != -1) || (!VM.allowArraySyntax() && (name.charAt(0) == '['))) return false; return true; }
  • 打赏
  • 举报
回复
skygege20 2015-07-24
求大神解决方案,我感觉错误不是在异常报错的位置呢
  • 打赏
  • 举报
回复
发帖
Web 开发

8.0w+

社区成员

Java Web 开发
社区管理员
  • Web 开发社区
加入社区
帖子事件
创建了帖子
2015-07-24 03:33
社区公告
暂无公告